package edu.sctu.wulixia.month6.day20150628;

import java.io.*;

/**
* Created by user05 on 2015/6/28.
*/
public class SerializableJson {


    //序列化将数据写入文件

    public void isSerializableJson(JsonAppbean jsonAppbean) throws IOException {
        File file = new File("D://Json//Appbean.txt");

            FileOutputStream fos = new FileOutputStream(file);
            ObjectOutputStream oos = new ObjectOutputStream(fos);
            oos.writeObject(jsonAppbean);
            System.out.println("序列化成功");

    }

    //反序列化
    public JsonAppbean isAntiSerializableJson () throws IOException, ClassNotFoundException {
        File file1 = new File("D://Json//Appbean.txt");


        FileInputStream fis = new FileInputStream(file1);
        ObjectInputStream ois = new ObjectInputStream(fis);

        JsonAppbean jsonAppbean = (JsonAppbean)ois.readObject();
        System.out.println("反序列化成功");

        return jsonAppbean;

    }
}
